const webpack = require('webpack')
const path = require('path')

module.exports = {
  mode: 'development',
  devtool: 'cheap-module-source-map', //"inline-source-map",
  entry: {
    GiswayEngine: './index.ts'
  },
  output: {
    path: __dirname,
    filename: '[name].js'
  },
  resolve: {
    //解决引用jsm包造成的dumplicate import问题
    alias: {
      three: path.resolve('./node_modules/three')
    },
    extensions: ['.ts', '.tsx', '.js']
  },
  module: {
    rules: [
      {
        test: /\.ts?$/,
        use: [
          {
            loader: 'ts-loader',
            options: {
              transpileOnly: true
            }
          }
        ],
        exclude: [/node_modules/, path.resolve(__dirname, 'examples/resources')]
      }
    ]
  },
  plugins: [
    // 忽略examples/resources下的所有内容
    new webpack.IgnorePlugin({
      resourceRegExp: /^\.\/examples\/resources\//,
    })
  ],
  devServer: {
    compress: true,
    historyApiFallback: true,
    host: '0.0.0.0',
    // host: 'localhost',
    // host: '192.168.219.145',
    // host: '192.168.2.41',
    port: 9008,
    hot: true,
    client: {
      overlay: false
    },
    static: {
      directory: path.join(__dirname, ''),
      watch: false,
      // 排除examples/resources目录不进行监控
      staticOptions: {
        ignored: ['**/examples/resources/**']
      }
    }
  },
  cache: {
    type: 'filesystem'
  },
}
